//
//  YCAllOrderView.m
//  HeartWorldClient
//
//  Created by 大锅 on 2017/7/21.
//  Copyright © 2017年 谭明权. All rights reserved.
//

#import "YCAllOrderview.h"

@interface YCAllOrderview()





@end

@implementation YCAllOrderview


-(void)awakeFromNib{
    
    [super awakeFromNib];
    [self configButtons];
}

-(void)configButtons{
    
    for (int i = 0; i < self.buttons.count; i ++) {
        
        UIButton *button = self.buttons[i];
        [button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
        
        if (i == 0) {
            
            self.lastSelectedButton = button;
            button.selected = YES;
        }
    }
}

-(void)clickButton:(UIButton *)btn{
    
    self.lastSelectedButton.selected = NO;
    self.lastSelectedButton = btn;
    
    NSInteger index = [self.buttons indexOfObject:btn];
    self.lineConstraint.constant = index * self.line.width;
    
    
    btn.selected = !btn.selected;
    
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(selectButton:)]) {
        [self.delegate selectButton:index];
    }
}




@end
